package ccuserinterface;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.Rectangle;
import java.net.URL;
import javax.swing.JLabel;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.SwingConstants;
public class ImageCreator {
	/**
	 * Static method that creates a JButton with a unique label, universal background and the desired bounds.
	 * @param the_button_name The display that will be on the button in text.
	 * @param the_position the bounds to put the button at
	 * @return JButton a jbutton customized for this program.
	 */
	public static JButton createButton(String the_button_name, Rectangle the_position)
	{
		//Get background button image.
		URL manu_image_url = Class.class.getClass().getResource("/Images/GlobalImages/PNG/ButtonImage.png");
		ImageIcon manu_image = new ImageIcon(manu_image_url, "Manuscript button Image");
		//scale image
		manu_image.setImage(manu_image.getImage().getScaledInstance(250, 75, Image.SCALE_SMOOTH));
		
		//create JButton
		JButton temp_button = new JButton("SomeButton Name", manu_image);
		temp_button.setBounds(the_position);
		//create the label for the JButton, add the tab at the beginning to center it on the button.
		JLabel text = new JLabel("		" + the_button_name, JLabel.CENTER);
		text.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
		text.setBounds(temp_button.getBounds());
		
		//add the text to the button and set button properties
		temp_button.add(text, BorderLayout.EAST);
		temp_button.setBorder(BorderFactory.createEmptyBorder());
		temp_button.setVerticalTextPosition(SwingConstants.CENTER);
		return temp_button;
	}

}
